package org.jeecg.modules.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.system.entity.SysPosition;
import org.jeecg.modules.system.mapper.SysPositionMapper;
import org.jeecg.modules.system.service.ISysPositionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Description: 职务表
 * @Author: jeecg-boot
 * @Date: 2019-09-19
 * @Version: V1.0
 */
@Service
public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, SysPosition> implements ISysPositionService {


    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean synchronizationFromOA() {
//        List<OaPositionVo> oaPositionVos = OaSyncUtils.getPostByNO();
//
//        SysPosition position = new SysPosition();
////        position.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
//        Wrapper<SysPosition> updateWrapper = new UpdateWrapper<>(position);
////        SysPosition position1 = new SysPosition();
////        position1.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_1));
//        super.remove(/*position1,*/ updateWrapper);
//
//        List<SysPosition> sysPositions = new ArrayList<>();
//        if (oaPositionVos != null && oaPositionVos.size() > 0) {
//            oaPositionVos.stream().forEach(positionVo -> {
//                SysPosition sysPosition = new SysPosition();
//                sysPosition.setEnabled(positionVo.getEnabled() ? String.valueOf(CommonConstant.DEL_FLAG_1) : String.valueOf(CommonConstant.DEL_FLAG_0));
//                sysPosition.setDelFlag(positionVo.getIsDeleted() ? String.valueOf(CommonConstant.DEL_FLAG_1) : String.valueOf(CommonConstant.DEL_FLAG_0));
//                sysPosition.setId(positionVo.getId() + "");
//                sysPosition.setName(positionVo.getName());
//                sysPosition.setCode(positionVo.getCode());
//                sysPosition.setCompanyId(positionVo.getOrgAccountId() != null ? String.valueOf(positionVo.getOrgAccountId()) : "");
//                sysPosition.setSort(positionVo.getSortId());
////                sysPosition.setDescription(positionVo.getDescription());
////                sysPosition.setParentId(positionVo.getSuperior0() + "");
////                super.saveOrUpdate(sysDepart);
//                if (StringUtils.isBlank(sysPosition.getCode())){
//                    sysPosition.setCode(ChineseCharacterUtil.getUpperCase(sysPosition.getName(), false));
////					JSONObject formData = new JSONObject();
////					formData.put("parentId",sysDepart.getParentId());
////					String[] codeArray = (String[]) FillRuleUtil.executeRule(FillRuleConstant.DEPART,formData);
////					sysDepart.setOrgCode(codeArray[0]);
////					String orgType = codeArray[1];
////					sysDepart.setOrgType(String.valueOf(orgType));
//                }
//                sysPositions.add(sysPosition);
//            });
//        }
//        if (sysPositions.size() == 0) {
//            return true;
//        }
//        return super.saveOrUpdateBatch(sysPositions);

        return false;
    }
}
